import React from "react"
import {NavLink} from "react-router-dom"
import $ from "jquery"

class brandFooter extends React.Component{
	constructor(props){
		super(props);
		this.state={
			list:[]
		}
	}
	componentDidMount(){
		$('#footer').css('display','block')
	}
	tap(){
		var brandId = location.href.split(':')[2].split('/')[3];
		var that = this;
		var obj= {};
		$.ajax({
			type:"get",
			url:"http://10.8.154.144:3000",
			data:{
				brandId:brandId
			},
			async:false,
			success:function(data){
				console.log(data.data.goods)
				var ob = data.data.goods;
				obj = {
					brandId:ob.gid,
					name:ob.productName,
					price:ob.vipshopPrice,
					img:ob.smallImage[0]
				}
				console.log(obj)
			}
		});
		$.ajax({
			type:"get",
			url:"http://10.8.154.144:3000/cart",
			async:true,
			data:obj,
			success:function(data){
				console.log(data)
			}
		});
	}
	
	tap1(){
		var brandId = location.href.split(':')[2].split('/')[3];
		$.ajax({
			type:"get",
			url:"http://10.8.154.144:3000/cart1",
			async:true,
			data:{brandId:brandId},
			success:function(data){
				console.log(data[0])
				window.location.href ="#cart";
			}
		});
	}
		render() {
		return (
			<div id="brandFooter">
				<i className="iconfont icon-gouwuchekong" onClick={this.tap1}></i>
				<button id="btt" onClick={this.tap.bind(this)}>加入购物车</button>
			</div>
		)
	}
}
export default brandFooter;